package com.zcn.io.web.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zcn.io.common.pojo.CommonResult;
import com.zcn.io.web.api.entity.NegotiateInfo;
import com.zcn.io.web.api.entity.ThawInfo;
import com.zcn.io.web.api.vo.ThawInfoVo;
import com.zcn.io.web.service.NegotiationService;
import com.zcn.io.web.service.ThawInfoService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @desc:
 * @author: 202438 邱建伟
 * @date: 2025/1/12 13:48
 * @Copyright (c) 2025, 江苏金恒信息科技股份有限公司
 */

@RestController
@AllArgsConstructor
@RequestMapping("/thawInfo")
public class ThawInfoController {

    private final ThawInfoService thawInfoService;

    @GetMapping("/list")
    public CommonResult<Page<ThawInfo>> list(Page<ThawInfo> page, ThawInfo negotiateInfo) {
        thawInfoService.list(page, negotiateInfo);
        return CommonResult.success(page);
    }

    @PostMapping("/save")
    public CommonResult<ThawInfo> save(@RequestBody ThawInfo negotiateInfo) {
        thawInfoService.save(negotiateInfo);
        return CommonResult.success(negotiateInfo);
    }

    @GetMapping("/getById")
    public CommonResult<ThawInfo> getById(@RequestParam String id) {
        return CommonResult.success(thawInfoService.getById(id));
    }

    @PostMapping("/updateById")
    public CommonResult<ThawInfo> updateById(@RequestBody ThawInfo negotiateInfo) {
        thawInfoService.updateById(negotiateInfo);
        return CommonResult.success(negotiateInfo);
    }

    @DeleteMapping("/deleteById")
    public CommonResult<String> deleteById(ThawInfo negotiateInfo) {
        thawInfoService.deleteById(negotiateInfo.getId());
        return CommonResult.success(negotiateInfo.getId());
    }

    @GetMapping("/listAllByPhoneCode")
    public CommonResult<List<ThawInfoVo>> listAllByPhoneCode(ThawInfo thawInfo) {
        return CommonResult.success(thawInfoService.listAllByPhoneCode(thawInfo));
    }
}
